package com.sky.controller.admin;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/shop")
@RestController
@Slf4j
public class AdminShopController {
    public static final String KEY ="SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;
@PutMapping("/{status}")
public Result putShop(@PathVariable Integer status){
    log.info("店铺状态：{}", status==0?"打样":"营业");
    ValueOperations valueOperations = redisTemplate.opsForValue();
    valueOperations.set(KEY,status);
    return Result.success();

}
@GetMapping("/status")
    public Result gatShop(){
    Integer status = (Integer) redisTemplate.opsForValue().get(KEY);

return Result.success(status);
}
}
